<%@ page language="java" import="java.sql.*" %>
<HTML>   
<HEAD><TITLE>Welcome</TITLE></HEAD>  
<BODY>

<%
	String user="";
	Connection conn=null;
	Statement st=null;

	String url = "jdbc:oracle:thin:@localhost:1521";
	String dbName = ":orcl";
	String driver = "oracle.jdbc.driver.OracleDriver";
	String userName = "scott"; 
	String password = "tiger";
	
	try{
		Class.forName(driver).newInstance();
		}catch(ClassNotFoundException e){
		e.printStackTrace();
		}	
		try{
			conn = DriverManager.getConnection(url+dbName,userName,password);
			st=conn.createStatement();
		}catch(SQLException e){
			e.printStackTrace();
		}catch(Exception e){
			e.printStackTrace();
		}
if(session.getAttribute("username")!=null && session.getAttribute("username")!="")
{
	user = session.getAttribute("username").toString();
%>
<table align=center border=0>
<tr><td align="center">Welcome <b><%= user%></td></tr>
</table>
<table align="center" border=1>
<TR>
<TH>Parameter Name<TH>Parameter Value(s)</TR>
<%
}
		try{
			ResultSet rs=null;
			 rs=st.executeQuery("select * from Thermostat_Information where username='"+user+"'");
			while(rs.next())
			{
				%>
				<tr><td><b>Name</td><td><%=rs.getString(1)%></td></tr>
				<tr><td><b>UUID</td><td><%=rs.getString(2)%></td></tr>
				<tr><td><b>API_Version</td><td><%=rs.getString(3)%></td></tr>
				<tr><td><b>Model</td><td><%=rs.getString(4)%></td></tr>
				<tr><td><b>FW_Version</td><td><%=rs.getString(5)%></td></tr>
				<tr><td><b>WLAN_FW_Version</td><td><%=rs.getString(6)%></td></tr>
				<%
			}
			rs.close();
		    }catch(SQLException e){
			e.printStackTrace();
		    }
			
		try{
			if(conn!=null)
			conn.close();
		}catch(SQLException e){
			e.printStackTrace();
		}

%>
</table>
<table align=center>
<form name=view action="">
<tr><td>
<a href="Thermostat_Info.jsp">View Thermostat Current Information</a>
</td></tr>
</form>
</table>
</body>
<html>


